import { HttpException, HttpStatus, Injectable } from '@nestjs/common';
import { UserDto } from './user.dto';

@Injectable()
export class UserService {
  getUserById(userId: string) {
    return { id: Number(userId), name: 'John' + userId }
  }
  login(body: UserDto) {
    // 缺少参数要抛出异常
    if (!body.userId || !body.pwd || !body.confirmPwd) {
      throw new HttpException('参数错误或缺少参数', HttpStatus.BAD_REQUEST);
    }
    return 'login success'
  }
}
